<style>
    .text-center {
        text-align: left !important;
    }
    .text-left {
        text-align: center !important;
    }
    .orders-list {
        width: 50%;
        /*background: #F2F2F2;*/
        padding: 15px;
        /*border: 1px solid #D2D2D2;*/
        /*border-radius: 10px;*/
    }
    .order-list {
        margin-bottom: 15px;
        padding-bottom: 15px;
        border-bottom: 1px solid #D2D2D2;
    }
    .order-list .form-group {
        margin-bottom: 0;
    }
</style>
<form id="" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="margin: 0 auto">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Id')} : </label>
        <label class="control-label col-xs-12 col-sm-2 text-center">{$data.id}</label>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')} : </label>
        <label class="control-label col-xs-12 col-sm-2 text-center">{$data.name}</label>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Granttime')} : </label>
        <label class="control-label col-xs-12 col-sm-2 text-center">{$data.granttime}</label>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Dealer_ids')} : </label>
        <label class="control-label col-xs-12 col-sm-6 text-center">{$data.dealername}</label>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Shoptotal')} : </label>
        <label class="control-label col-xs-12 col-sm-2 text-center">¥ {$data.total}</label>
    </div>


    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">————————— </label>
        <label class="control-label col-xs-12 col-sm-2 text-left">店铺订单列表</label>
        <label class="control-label col-xs-12 col-sm-2">————————— </label>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Distributor')} : </label>
        <div class="col-xs-12 col-sm-3">

            <select class="form-control consumer_id" shop_id="{$data.shop_id}" onchange="order(this)">
                <option value="0">不限</option>
                {foreach name="consumer_list" item="vo"}
                <option value="{$key}">{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>
    {notempty name="$orders"}
    <div class="orders-list">
        {foreach name="$orders" item="v"}
        <div class="order-list">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-8 text-center">{:__('Ordernum')}: {$v.ordernum}</label>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-10 text-center">{$v.goods}</label>
                <label class="control-label col-xs-12 col-sm-2 text-center" onclick="change(this)"><i class="fa fa-chevron-right"></i></label>
            </div>
            <div style="display: none;color: #9F9F9F">
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-6 text-center">{:__('Ordertime')}: {$v.ordertime}</label>
                    <label class="control-label col-xs-12 col-sm-6 text-center">{:__('Money')}: ¥{$v.money}</label>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-6 text-center">{:__('Recipient')}: {$v.receiver}</label>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-6 text-center">{:__('Phone')}: {$v.phone}</label>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-6 text-center">{:__('Dealer_ids')}: {$v.dealername}</label>
                </div>
            </div>
        </div>
        {/foreach}
    </div>
    {/notempty}

</form>
<script type="text/javascript">
    function change(t)
    {
        if($(t).parent().next().css('display')=='none'){
            $(t).parent().next().css('display','block');
            $(t).html('<i class="fa fa-chevron-down"></i>');
        }else{
            $(t).parent().next().css('display','none');
            $(t).html('<i class="fa fa-chevron-right"></i>');
        }
    }
    function order(t)
    {
        var shop_id = $(t).attr('shop_id');
        var consumer_id = $(t).val();
        $.post('Shop/getOrderListByConsumerId',{shop_id:shop_id,consumer_id:consumer_id},function (data){
            if (data.status){
                var orders = data.orders;
                var orders_html = '';
                for (var i in orders){
                    orders_html += '<div class="order-list">' +
                                        '<div class="form-group">' +
                                            '<label class="control-label col-xs-12 col-sm-8 text-center">{:__(\'Ordernum\')}: '+ orders[i].ordernum+'</label>' +
                                        '</div>' +
                                        '<div class="form-group">\n' +
                                            '<label class="control-label col-xs-12 col-sm-10 text-center">'+ orders[i].goods+'</label>\n' +
                                            '<label class="control-label col-xs-12 col-sm-2 text-center" onclick="change(this)"><i class="fa fa-chevron-right"></i></label>\n' +
                                        '</div>' +
                                        '<div style="display: none;color: #9F9F9F">\n' +
                                            '<div class="form-group">\n' +
                                                '<label class="control-label col-xs-12 col-sm-6 text-center">{:__(\'Ordertime\')}: '+ orders[i].ordertime +'</label>\n' +
                                                '<label class="control-label col-xs-12 col-sm-6 text-center">{:__(\'Money\')}: ¥'+ orders[i].money +'</label>\n' +
                                            '</div>\n' +
                                            '<div class="form-group">\n' +
                                                '<label class="control-label col-xs-12 col-sm-6 text-center">{:__(\'Recipient\')}: '+ orders[i].receiver +'</label>\n' +
                                            '</div>\n' +
                                            '<div class="form-group">\n' +
                                                '<label class="control-label col-xs-12 col-sm-6 text-center">{:__(\'Phone\')}: '+ orders[i].phone +'</label>\n' +
                                            '</div>\n' +
                                            '<div class="form-group">\n' +
                                                '<label class="control-label col-xs-12 col-sm-6 text-center">{:__(\'Dealer_ids\')}: '+ orders[i].dealername +'</label>\n' +
                                            '</div>\n' +
                                        '</div>' +
                                    '</div>'
                }
                $('.orders-list').html(orders_html);
            }else{
                $('.orders-list').text('');
            }
        });
    }
</script>
